Exemplo n.º 1
0
        public void LoadDatesandTimes()
        {
            Application.DiagnosticsLog("KC_VarDt:" + ThisForm.Variables("VarDtModified").Value);
            Application.DiagnosticsLog("KC_VarDt:" + ThisForm.Variables("VarDtCreated").Value);

            var currentUser = Application.Variables("VarCRMUserID").GetValueOfString(string.Empty);

            if (string.IsNullOrEmpty(currentUser))
            {
                currentUser = Application.Variables("VarMGUserName").GetValueOfString(string.Empty);
            }
            LoadCollectionResponseData loadResponse = IDOClient.LoadCollection("CRMUserNames", "CRMUserID,LocalTimeZone",
                                                                               string.Format("CRMUserID = '{0}' OR Username = '******'", currentUser), "", 0);
            var timeZone = TimeZoneInfo.Local.Id;

            if (loadResponse.Items.Count > 0)
            {
                timeZone = loadResponse[0, 1].Value;
                Application.DiagnosticsLog(string.Format("User '{0}' time zone set to: {1}", currentUser, timeZone));

                if (string.IsNullOrEmpty(timeZone))
                {
                    // Fall back to local time
                    timeZone = TimeZoneInfo.Local.Id;
                    Application.ShowMessage(Application.GetStringValue("mUserTimeZoneNotSet"));
                }
            }

            var now          = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, timeZone);
            var modifiedDate = ThisForm.Variables("VarDtModified").GetValueOfDateTime(RoundUp(now, TimeSpan.FromMinutes(5)));
            var createdDate  = ThisForm.Variables("VarDtCreated").GetValueOfDateTime(RoundUp(now, TimeSpan.FromMinutes(5)));

            ThisForm.Variables("VarDtModified").SetValue(ConvertDtToTimeZone(modifiedDate, timeZone));
            ThisForm.Variables("VarDtCreated").SetValue(ConvertDtToTimeZone(createdDate, timeZone));
        }
Exemplo n.º 2
0
        private string GetSurveyAssociationValues(string associationID)
        {
            var req = new InvokeRequestData()
            {
                IDOName    = "CRMSurveyAssociation",
                MethodName = "GetAssociationValuesByAssociationID",
                Parameters = new InvokeParameterList()
                {
                    new InvokeParameter(associationID),
                    new InvokeParameter("SurveyID,EntityType,EntityID")
                }
            };

            try
            {
                InvokeResponseData resp = null;
                resp = IDOClient.Invoke(req);
                return(resp.Parameters[1].Value);
            }
            catch (Exception ex)
            {
                Application.DiagnosticsLog(ex.ToString());
                return(string.Empty);
            }
        }
Exemplo n.º 3
0
        public void idoInsert()
        {
            LogMessage("idoInsert");
            UpdateCollectionRequestData insert = new UpdateCollectionRequestData(ido);
            IDOUpdateItem itm = new IDOUpdateItem(UpdateAction.Insert);

            //ONE PROPERTY
            if (!properties.Contains(","))
            {
                itm.Properties.Add(properties, values);
                insert.Items.Add(itm);
            }
            else
            {
                string[] propertyArray = properties.Split(',');
                string[] valueArray    = values.Split(',');
                for (int i = 0; i < propertyArray.Length; i++)
                {
                    itm.Properties.Add(propertyArray[i], valueArray[i]);
                    insert.Items.Add(itm);
                }
            }
            stopwatch.Start();
            IDOClient.UpdateCollection(insert);
            stopwatch.Stop();
            stopwatch.Reset();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Generates a new key based on the table name.
        /// </summary>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public string IntGetNewKey(string tableName)
        {
            var key = string.Empty;
            var req = new InvokeRequestData
            {
                IDOName    = "CRMTableKey",
                MethodName = "CRMNewKeySp"
            };

            req.Parameters.Add(tableName);
            req.Parameters.Add(key, true);

            InvokeResponseData resp = null;

            try
            {
                resp = IDOClient.Invoke(req);
            }
            catch (Exception ex)
            {
                Application.ShowMessage(ex.Message);
            }

            if (resp != null)
            {
                key = resp.Parameters[1].Value;
            }

            return(key);
        }
        public void SetReturnVariables()
        {
            var id                = ThisForm.ModalChildForm.PrimaryIDOCollection.CurrentItem.Properties["ID"].GetValueOfString(string.Empty);
            var propList          = "AlternateKeySuffix,ID";
            var req               = IDOClient.LoadCollection("CRMSalesOrder", propList, "ID = '" + id + "'", string.Empty, 1);
            var summary           = req[0, "AlternateKeySuffix"].GetValue(string.Empty);
            var description       = Application.GetStringValue("sSalesOrderInsert");
            var jsonResult        = string.Empty;
            var toastEntityFilter = string.Empty;

            description       = description.Replace("%1", string.Format("[{0}]({1} {2})", summary, "CRMSalesOrder", id));
            toastEntityFilter = string.Format("ID = '{0}'", id);
            var toastJson = new InvokeRequestData()
            {
                IDOName    = "CRMToastService",
                MethodName = "GenerateToastJson",
                Parameters = new InvokeParameterList()
                {
                    new InvokeParameter("Create"),
                    new InvokeParameter(description),
                    new InvokeParameter(string.Empty),
                    new InvokeParameter("barcode"),
                    new InvokeParameter()
                    {
                        ByRef = true, Value = jsonResult
                    }
                }
            };
            var response = IDOClient.Invoke(toastJson);

            jsonResult = response.Parameters[response.Parameters.Count - 1].Value;
            Application.DiagnosticsLog(jsonResult + Environment.NewLine + response.ReturnValue);
            Application.Variables("VarCRMToastEntityFilter").SetValue(toastEntityFilter);
            Application.Variables("VarCRMToastConfig").SetValue(jsonResult);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Enable / Disable the Quick Add Product Menu
        /// -- Enable: if BOE is disabled --
        /// -- Disable: if BOE is enabled --
        /// </summary>
        public void EnableDisableProductMenu()
        {
            var integrationCollection = IDOClient.LoadCollection("CRMIntegration", "Enabled", "Name = 'Back Office Extension'", string.Empty, 1);
            int enabled = integrationCollection[0, "Enabled"].GetValue <int>() == 1 ? 0 : 1;

            string filter = string.Format("Action = '{0}'", "CRMQuickAddProduct");
            LoadCollectionResponseData loadResponse = IDOClient.LoadCollection("CRMMenus", "Enabled", filter, string.Empty, 1);

            var updateReq = new UpdateCollectionRequestData()
            {
                IDOName            = "CRMMenus",
                RefreshAfterUpdate = true
            };

            foreach (var current in loadResponse.Items)
            {
                var updateItem = new IDOUpdateItem()
                {
                    ItemID = current.ItemID,
                    Action = UpdateAction.Update
                };

                updateItem.Properties.Add("Enabled", enabled);
                updateReq.Items.Add(updateItem);
            }

            IDOClient.UpdateCollection(updateReq);
        }
Exemplo n.º 7
0
        public void AddAccountPlanningCycle()
        {
            UpdateCollectionRequestData req = new UpdateCollectionRequestData();

            req.IDOName            = "CRMPlanningCycleAssociations";
            req.RefreshAfterUpdate = true;
            var accountID            = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID");
            var count                = ThisForm.ModalChildForm.PrimaryIDOCollection.GetNumEntries();
            var accountPlanningCycle = string.Empty;

            for (var curIndex = 0; curIndex < count; curIndex++)
            {
                if (ThisForm.ModalChildForm.PrimaryIDOCollection.GetObjectProperty("CRMRecordSelected", curIndex) == "1")
                {
                    IDOUpdateItem newItem;
                    string        planningCycleID = ThisForm.ModalChildForm.PrimaryIDOCollection.GetObjectProperty("ID", curIndex);
                    if (planningCycleID == null)
                    {
                        return;
                    }

                    if (!IsDuplicateAccountPlanningCycleRecord(accountID, planningCycleID))
                    {
                        newItem = MapAccountPlanningCycle(accountID, planningCycleID);
                        req.Items.Add(newItem);
                    }
                }
            }

            IDOClient.UpdateCollection(req);
            ThisForm.PrimaryIDOCollection.RefreshKeepCurIndex();
            return;
        }
Exemplo n.º 8
0
        private void CallAddSurveys(string surveys)
        {
            var req = new InvokeRequestData()
            {
                IDOName    = "CRMSurveyAssociation",
                MethodName = "AddSurveyAssociationItems",
                Parameters = new InvokeParameterList()
                {
                    new InvokeParameter(surveys)
                }
            };

            try
            {
                InvokeResponseData resp = null;
                resp = IDOClient.Invoke(req);
            }
            catch (Exception ex)
            {
                Application.ShowMessage("Error: " + ex.Message);
                Application.DiagnosticsLog("Error: " + ex.Message);
                return;
            }
            finally
            {
                ThisForm.PrimaryIDOCollection.RefreshKeepCurIndex();
            }
        }
Exemplo n.º 9
0
        private void AddAccountCampaign()
        {
            UpdateCollectionRequestData req = new UpdateCollectionRequestData();

            req.IDOName            = "CRMCampaignAccount";
            req.RefreshAfterUpdate = true;

            string primaryID = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID");
            int    count     = ThisForm.ModalChildForm.PrimaryIDOCollection.GetNumEntries();

            for (var curIndex = 0; curIndex < count; curIndex++)
            {
                if (ThisForm.ModalChildForm.PrimaryIDOCollection.GetObjectProperty("CRMRecordSelected", curIndex) == "1")
                {
                    IDOUpdateItem newItem;
                    var           childID = ThisForm.ModalChildForm.PrimaryIDOCollection.GetObjectProperty("ID", curIndex);

                    if (childID == null)
                    {
                        return;
                    }

                    if (!IsDuplicateCampaignAccountRecord(primaryID, childID))
                    {
                        newItem = MapCampaignAccount(primaryID, childID);
                        req.Items.Add(newItem);
                    }
                }
            }

            IDOClient.UpdateCollection(req);
            return;
        }
Exemplo n.º 10
0
        public void AddAccountOpportunity()
        {
            UpdateCollectionRequestData req = new UpdateCollectionRequestData();

            req.IDOName            = "CRMOPPORTUNITYRESELLER";
            req.RefreshAfterUpdate = true;
            string accountID     = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID");
            string opportunityID = ThisForm.ModalChildForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID");

            IDOUpdateItem newItem;

            if (string.IsNullOrWhiteSpace(opportunityID))
            {
                return;
            }

            string description = ThisForm.ModalChildForm.PrimaryIDOCollection.GetCurrentObjectProperty("Description");

            if (IsDuplicate(opportunityID))
            {
                Application.ShowMessage(Application.GetStringValue("mIsAlreadyAssociatedToThisAccount").Replace("%1", description));
                return;
            }

            newItem = MapContactOpportunitItem(accountID, opportunityID);
            req.Items.Add(newItem);

            IDOClient.UpdateCollection(req);
            ThisForm.PrimaryIDOCollection.RefreshKeepCurIndex();
            return;
        }
Exemplo n.º 11
0
        private void AssociateAccountContact()
        {
            var req = new UpdateCollectionRequestData
            {
                IDOName            = "CRMContactAccount",
                RefreshAfterUpdate = true
            };
            string accountId = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID");
            int    count     = ThisForm.ModalChildForm.PrimaryIDOCollection.GetNumEntries();

            for (int curIndex = 0; curIndex < count; curIndex++)
            {
                if (ThisForm.ModalChildForm.PrimaryIDOCollection.GetObjectProperty("CRMRecordSelected", curIndex) == "1")
                {
                    string contactId           = ThisForm.ModalChildForm.PrimaryIDOCollection.GetObjectProperty("ID", curIndex);
                    var    existingAssociation = IDOClient.LoadCollection("CRMContactAccount", "AccountID, ContactID", string.Format("AccountID = '{0}' AND ContactID = '{1}'", accountId, contactId), string.Empty, 1);
                    if (existingAssociation.Items.Count == 0)
                    {
                        req.Items.Add(MapNewItem(contactId, accountId));
                    }
                    //Application.ShowMessage(Application.GetStringValue("sRecordExisted"));
                }
            }
            try
            {
                IDOClient.UpdateCollection(req);
            }
            catch (Exception ex)
            {
                Application.ShowMessage(ex.Message);
                Application.DiagnosticsLog(ex.Message);
            }
            ThisForm.PrimaryIDOCollection.RefreshKeepCurIndex();
        }
Exemplo n.º 12
0
        public LoadCollectionResponseData getEventStatus(string eventName)
        {
            LoadCollectionRequestData Load = new LoadCollectionRequestData();

            Load.IDOName = "EventStates";
            Load.PropertyList.Add("EventName");
            Load.PropertyList.Add("Status");
            Load.PropertyList.Add("Originator");
            Load.PropertyList.Add("EventParmId");
            Load.Filter    = "EventName = '" + eventName + "' AND Status = '2'";
            Load.OrderBy   = "";
            Load.RecordCap = 100;
            LoadCollectionResponseData response = IDOClient.LoadCollection(Load);

            if (response.Items.Count > 0)
            {
                ThisForm.Variables("varDebug").Value += response[0, "EventName"].Value + "\n";
                ThisForm.Variables("varDebug").Value += response[0, "Status"].Value + "\n";
                ThisForm.Variables("varDebug").Value += response[0, "Originator"].Value + "\n";
                for (int i = 0; i < response.Items.Count; i++)
                {
                    ThisForm.Variables("varDebug").Value += response[i, "EventParmId"].Value + "\n";
                }
            }
            return(response);
        }
Exemplo n.º 13
0
        public List <string> setTableNamesFromSelectedIdo(string ido)
        {
            ThisForm.Variables("varDebug").Value += "setTableNamesFromSelectedIdo - " + ido + "\n";
            string filter = "CollectionName = '" + ido + "'";

            string sso          = ThisForm.Variables("varSSO").Value = "0";
            string serverId     = ThisForm.Variables("varServerId").Value = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ServerID");
            string suiteContext = ThisForm.Variables("varSuiteContext").Value = "MONGOOSE/IDORequestService/ido";
            string httpMethod   = ThisForm.Variables("varHttpMethod").Value = "GET";
            string methodName   = ThisForm.Variables("varMethodName").Value = "/load/IdoTables?properties=TableName&filter=" + filter;
            string parameters   = ThisForm.Variables("varParameters").Value = "[{\"Name\":\"Accept\",\"Type\":\"header\",\"Value\":\"application/json\"}, " +
                                                                              "{\"Name\":\"X-Infor-MongooseConfig\",\"Type\":\"header\",\"Value\":\"" + ThisForm.Variables("varMongooseConfig").Value + "\"}]";
            string contentType = ThisForm.Variables("varContentType").Value = "text/plain";
            string timeout     = ThisForm.Variables("varTimeout").Value = "10000";

            InvokeRequestData IDORequest = new InvokeRequestData();

            IDORequest.IDOName    = "IONAPIMethods";
            IDORequest.MethodName = "InvokeIONAPIMethod";
            IDORequest.Parameters.Add(sso);
            IDORequest.Parameters.Add(serverId);
            IDORequest.Parameters.Add(new InvokeParameter(suiteContext));
            IDORequest.Parameters.Add(new InvokeParameter(httpMethod));
            IDORequest.Parameters.Add(new InvokeParameter(methodName));
            IDORequest.Parameters.Add(new InvokeParameter(parameters));
            IDORequest.Parameters.Add(new InvokeParameter(contentType));
            IDORequest.Parameters.Add(new InvokeParameter(timeout));
            IDORequest.Parameters.Add(IDONull.Value); //ResponseCode 8
            IDORequest.Parameters.Add(IDONull.Value); //ResponseContent 9
            IDORequest.Parameters.Add(IDONull.Value); //ResponseHeaders 10
            IDORequest.Parameters.Add(IDONull.Value); //ResponseInfobar 11

            InvokeResponseData response = IDOClient.Invoke(IDORequest);

            if (response.IsReturnValueStdError())
            {
                ThisForm.Variables("varDebug").Value += "Error: " + methodName + "\r\nResponseCode: " + response.Parameters[8].Value + "\r\nInfobar " + response.Parameters[11].Value + "\n";
            }

            //ThisForm.Variables("varDebug").Value += response.Parameters[9].Value + "\n";

            MongooseResponse mongooseResponseObj = JsonConvert.DeserializeObject <MongooseResponse>(response.Parameters[9].Value);

            if (mongooseResponseObj.Success && mongooseResponseObj.Items != null)
            {
                List <string> tables = new List <string>();
                for (int i = 0; i < mongooseResponseObj.Items.Length; i++)
                {
                    tables.Add(mongooseResponseObj.Items[i].TableName);
                }
                return(tables);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 14
0
        private bool IsDuplicateCampaignAccountRecord(string AccountID, string childPropertyID)
        {
            bool isExist  = false;
            var  response = IDOClient.LoadCollection(string.Format("CRMCampaignAccount"), "ID", string.Format("AccountID = '{0}' and CampaignID = '{1}'", AccountID, childPropertyID), "", -1).Items.Count;

            if (response > 0)
            {
                isExist = true;
            }
            return(isExist);
        }
Exemplo n.º 15
0
        public void EmailRelated()
        {
            var emailList        = string.Empty;
            var contactIdList    = string.Empty;
            var emailQueryFilter = "EntityID in ({0}) and IsPrimary = 1";
            var accountId        = ThisForm.PrimaryIDOCollection.CurrentItem.Properties["ID"].GetValueOfString(string.Empty);
            var acctFilter       = string.Format("AccountID='{0}'", accountId);
            var req = new LoadCollectionRequestData("CRMContact", "ID", acctFilter, "", 0);

            Application.DiagnosticsLog("EmailRelated: Load Collection contact");
            var resp      = IDOClient.LoadCollection(req);
            var mailToUrl = "mailto:";

            if (resp.Items != null && resp.Items.Count > 0)
            {
                for (int i = 0; i < resp.Items.Count; i++)
                {
                    Application.DiagnosticsLog("EmailRelated: " + resp.Items.Count.ToString());
                    var tempId = resp.Items[i].PropertyValues[0].Value;
                    // filter ID values need wrapped in single quotes to pass through load collection
                    if (!string.IsNullOrEmpty(contactIdList))
                    {
                        contactIdList += @",";
                    }
                    contactIdList += @"'" + tempId + @"'";
                }
            }
            var emailFilter = string.Format(emailQueryFilter, contactIdList);

            if (!string.IsNullOrEmpty(contactIdList))
            {
                var emailReq = new LoadCollectionRequestData("CRMEmail", "Address", emailFilter, "Address", 0);
                Application.DiagnosticsLog("EmailRelated: Load Collection email");
                var emailResp = IDOClient.LoadCollection(emailReq);

                for (int i = 0; i < emailResp.Items.Count; i++)
                {
                    var tempEmail = emailResp.Items[i].PropertyValues[0].Value;

                    if (!string.IsNullOrEmpty(emailList))
                    {
                        emailList += ";";
                    }
                    emailList += tempEmail;
                }
            }

            mailToUrl += emailList;

            ThisForm.Variables("VarMailToUrl").SetValue(mailToUrl);

            ThisForm.Components["linkEmailRelated"].SetValue(mailToUrl);
            ThisForm.Components["linkEmailRelated"].Caption = Application.GetStringValue("sEmailRelated");
        }
Exemplo n.º 16
0
        private bool IsDuplicateAccountPlanningCycleRecord(string AccountID, string childPropertyID)
        {
            bool isExist  = false;
            var  response = IDOClient.LoadCollection("CRMPlanningCycleAssociations", "ID", string.Format("AccountID = '{0}' and PlanningCycleID = '{1}'", AccountID, childPropertyID), "", -1).Items.Count;

            if (response > 0)
            {
                isExist = true;
            }
            return(isExist);
        }
Exemplo n.º 17
0
        private bool IsDuplicate(string opportunityID)
        {
            string accountID = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID");
            var    records   = IDOClient.LoadCollection("CRMOPPORTUNITYRESELLER", "OPPORTUNITYID", "RESELLERID='" + accountID + "'", string.Empty, -1);

            if (records.Items != null && records.Items.Count > 0 && (records.Items.FindIndex(item => opportunityID.Equals(item.PropertyValues[0].Value)) >= 0))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 18
0
        public void ConfigureComponent()
        {
            // Custom Setting determines if the VisitPlanning related items can be visible
            var oResp = IDOClient.LoadCollection("CRMCustomSetting", "DataValue",
                                                 "Category = 'Visit Planning'", string.Empty, 1);

            if (oResp.Items.Count > 0)
            {
                var settingValue = oResp.Items[0].PropertyValues[0].GetValue(string.Empty);
                visitOverride = !settingValue.Equals("False", StringComparison.OrdinalIgnoreCase);
            }
            EnableComponents(visitOverride);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Gets the number of activities for the Account. That will be used as badge to display in Activity Related section
        /// </summary>
        public void GetUpcomingActivitiesCount()
        {
            string ActivityCount = "0";
            string accountId     = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID");

            if (accountId != null)
            {
                LoadCollectionResponseData loadresponse = IDOClient.LoadCollection("CRMACCOUNTACTIVITIESRRELATEDVIEWs", "Summary", "EntityID='" + accountId + "' and EntityType='CRMAccount' and Completed IS NULL and IsFirstUncompleted=1", "", -1);
                if (loadresponse != null)
                {
                    ActivityCount = loadresponse.Items.Count == 1 ? "STRINGS(sCRMItemCount)" : string.Format("FORMAT(sCRMItemsCount,{0})", loadresponse.Items.Count.ToString());
                }
            }
            ThisForm.Variables("VarActivityCount").SetValue(ActivityCount);
        }
Exemplo n.º 20
0
        public void StartNewSurvey()
        {
            var variable = ThisForm.Variables("VarRelationalItemsPointOfReference").Value.Trim();

            var sp = variable.Split(';');

            string[] properties;
            var      associationID = (sp.Length > 2) ? (sp[2] ?? string.Empty) : string.Empty;
            string   newID         = string.Empty;
            string   resultMessage = string.Empty;

            //returns SurveyID, EntityType, EntitiyID, NEED TO GET STATUS TO CHECK
            properties = GetSurveyAssociationValues(associationID).Split(';');

            var insertReq = new InvokeRequestData()
            {
                IDOName    = "CRMSurveyRecord",
                MethodName = "InsertSurveyRecord",
                Parameters = new InvokeParameterList()
                {
                    new InvokeParameter(properties[0]),
                    new InvokeParameter(properties[1]),
                    new InvokeParameter(properties[2]),
                    new InvokeParameter(newID),
                    new InvokeParameter(resultMessage)
                }
            };

            try
            {
                InvokeResponseData resp = null;
                resp = IDOClient.Invoke(insertReq);
                if (int.Parse(resp.ReturnValue) == 0)
                {
                    ThisForm.Variables("VarSurveyRecordID").Value = resp.Parameters[3].Value;
                    ThisForm.GenerateEvent("LaunchSurveyRecord");
                }
                else
                {
                    throw new Exception(resp.Parameters[4].Value);
                }
            }
            catch (Exception ex)
            {
                Application.ShowMessage(ex.Message);
                return;
            }
        }
Exemplo n.º 21
0
        public void ValidateInProgressSurveys()
        {
            var variable = ThisForm.Variables("VarRelationalItemsPointOfReference").Value.Trim();
            var sp       = variable.Split(';');

            string[] properties;
            var      associationID = (sp.Length > 2) ? (sp[2] ?? string.Empty) : string.Empty;
            string   resultMessage = string.Empty;
            string   result;

            //returns SurveyID, EntityType, EntitiyID
            properties = GetSurveyAssociationValues(associationID).Split(';');
            int inProgress;
            var req = new InvokeRequestData()
            {
                IDOName    = "CRMSurveyRecord",
                MethodName = "PreInsertValidateInProgress",
                Parameters = new InvokeParameterList()
                {
                    new InvokeParameter(properties[1]),
                    new InvokeParameter(properties[2]),
                    new InvokeParameter(properties[0]),
                    new InvokeParameter(resultMessage)
                }
            };

            try
            {
                InvokeResponseData resp = null;
                resp       = IDOClient.Invoke(req);
                inProgress = int.Parse(resp.ReturnValue);
            }
            catch (Exception ex)
            {
                Application.ShowMessage(ex.ToString());
                return;
            }
            if (inProgress != 0)
            {
                ThisForm.GenerateEvent("SurveyInProgress");
            }
            else
            {
                ThisForm.GenerateEvent("NoSurveyInProgress");
            }
        }
Exemplo n.º 22
0
        public void CalculateAccountKPIs(string username)
        {
            var req = new LoadCollectionRequestData("CRMAccountManagerKPI",
                                                    "WinPercent, TotalPotential, TotalSales", string.Format("Username='******'", username), "", 1);
            var resp = IDOClient.LoadCollection(req);

            decimal salesPotential = 0.00M, actualSales = 0.00M, wins = 0.00M;

            if (resp.Items != null && resp.Items.Count > 0)
            {
                foreach (var t in resp.Items)
                {
                    if (t.PropertyValues.Count > 0 && !string.IsNullOrEmpty(t.PropertyValues[0].Value))
                    {
                        wins = t.PropertyValues[0].GetValue <decimal>();
                    }

                    if (t.PropertyValues.Count > 1 && !string.IsNullOrEmpty(t.PropertyValues[1].Value))
                    {
                        salesPotential = t.PropertyValues[1].GetValue <decimal>();
                    }

                    if (t.PropertyValues.Count > 2 && !string.IsNullOrEmpty(t.PropertyValues[2].Value))
                    {
                        actualSales = t.PropertyValues[2].GetValue <decimal>();
                    }
                }
            }

            ThisForm.Variables("VarKPIPipelineData").SetValue(FormatNumberForKPIDisplay(salesPotential));
            ThisForm.Variables("VarKPIWinsData").SetValue(FormatNumberForKPIDisplay(actualSales));

            if (wins > 0)
            {
                ThisForm.Variables("VarKPIWinRateData").SetValue(wins.ToString("P0",
                                                                               new NumberFormatInfo {
                    PercentPositivePattern = 1, PercentNegativePattern = 1
                }));
            }
            else
            {
                ThisForm.Variables("VarKPIWinRateData").SetValue("N/A");
            }
        }
Exemplo n.º 23
0
        public void ContinueInProgressSurvey()
        {
            var variable = ThisForm.Variables("VarRelationalItemsPointOfReference").Value.Trim();
            var sp       = variable.Split(';');

            string[] properties;
            var      accordionType = (sp.Length > 1) ? (sp[1] ?? string.Empty) : string.Empty;
            var      associationID = (sp.Length > 2) ? (sp[2] ?? string.Empty) : string.Empty;
            var      eventName     = (sp.Length > 3) ? (sp[3] ?? string.Empty) : string.Empty; // event or itemid
            string   NewID         = string.Empty;

            //returns SurveyID, EntityType, EntitiyID
            properties = GetSurveyAssociationValues(associationID).Split(';');

            var insertReq = new InvokeRequestData()
            {
                IDOName    = "CRMSurveyRecord",
                MethodName = "GetInProgressSurvey",
                Parameters = new InvokeParameterList()
                {
                    new InvokeParameter(properties[1]),
                    new InvokeParameter(properties[2]),
                    new InvokeParameter(properties[0]),
                    new InvokeParameter(NewID)
                }
            };

            try
            {
                InvokeResponseData resp = null;
                resp = IDOClient.Invoke(insertReq);
                ThisForm.Variables("VarSurveyRecordID").SetValue(resp.Parameters[3].GetValue(String.Empty));
            }
            catch (Exception ex)
            {
                Application.ShowMessage(ex.ToString());
                return;
            }
            ThisForm.GenerateEvent("LaunchSurveyRecord");
        }
Exemplo n.º 24
0
        public LoadCollectionResponseData getEventOutputParameters(string eventParmId)
        {
            LoadCollectionRequestData Load = new LoadCollectionRequestData();

            Load.IDOName = "EventOutputParameters";
            Load.PropertyList.Add("Name");
            Load.PropertyList.Add("Value");
            Load.PropertyList.Add("Originator");
            Load.PropertyList.Add("EventParmId");
            Load.PropertyList.Add("EventName");
            Load.Filter    = "EventParmId = '" + eventParmId + "'";
            Load.OrderBy   = "";
            Load.RecordCap = 10;
            LoadCollectionResponseData response = IDOClient.LoadCollection(Load);

            //ThisForm.Variables("varDebug").Value += "\n\nEvent Output Parameters\n";
            //ThisForm.Variables("varDebug").Value += response[0, "EventName"].Value + "\n";
            //ThisForm.Variables("varDebug").Value += response[0, "EventParmId"].Value + "\n";
            //ThisForm.Variables("varDebug").Value += response[0, "Originator"].Value + "\n";

            return(response);
        }
Exemplo n.º 25
0
        public void OnLocationChange()
        {
            if (string.IsNullOrWhiteSpace(ThisForm.Variables("VarAccountIdComponentKey").Value) ||
                string.IsNullOrWhiteSpace(ThisForm.Variables("VarLocationIdComponentKey").Value) ||
                string.IsNullOrWhiteSpace(ThisForm.Variables("VarAccountingEntityComponentKey").Value))
            {
                return;
            }
            var accountIdComponentKey        = ThisForm.Variables("VarAccountIdComponentKey").Value;
            var locationIdComponentKey       = ThisForm.Variables("VarLocationIdComponentKey").Value;
            var accountingEntityComponentKey = ThisForm.Variables("VarAccountingEntityComponentKey").Value;

            if (!ThisForm.Components.ContainsKey(accountIdComponentKey) ||
                !ThisForm.Components.ContainsKey(locationIdComponentKey) ||
                !ThisForm.Components.ContainsKey(accountingEntityComponentKey))
            {
                return;
            }
            var integrationEnabled = Application.Variables("VarCRMIsBOEEnabled").Value;
            var accountID          = ThisForm.Components[accountIdComponentKey].GetValueOfString(string.Empty);

            if (integrationEnabled == "1" && string.IsNullOrWhiteSpace(accountID))
            {
                var locationId = ThisForm.Components[locationIdComponentKey].GetValueOfString(string.Empty);
                if (string.IsNullOrWhiteSpace(locationId))
                {
                    ThisForm.Components[accountingEntityComponentKey].SetValue(string.Empty);
                    return;
                }
                var request  = new LoadCollectionRequestData("CRMLocation", "SORAccountingEntityID", string.Format("ID='{0}'", locationId), string.Empty, 1);
                var response = IDOClient.LoadCollection(request);
                if (response != null && response.Items.Count > 0)
                {
                    ThisForm.Components[accountingEntityComponentKey].SetValue(response.Items[0].PropertyValues[0].GetValue(string.Empty));
                }
            }
        }
Exemplo n.º 26
0
        private void SetAddress()
        {
            var entityID = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID");
            var filter   = string.Format("EntityID='{0}'", entityID);

            // Is VarAddressTypeFilter set?
            var addressTypeFilter = ThisForm.Variables("VarAddressTypeFilter").GetValueOfString(string.Empty);

            if (!string.IsNullOrEmpty(addressTypeFilter))
            {
                filter = string.Format("{0} and {1}", filter, addressTypeFilter);
            }

            var resp = IDOClient.LoadCollection("CRMAddress", "ID,MailingAddressDer", filter, string.Empty, 1);

            if (resp.Items.Count > 0)
            {
                ThisForm.Components["txtAddress"].SetValue(resp[0, "MailingAddressDer"].GetValue(string.Empty));
                if (string.IsNullOrEmpty(ThisForm.Variables("VarAddressID").GetValueOfString(string.Empty)))
                {
                    ThisForm.Variables("VarAddressID").SetValue(resp[0, "ID"].GetValue(string.Empty));
                }
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Insert trxHeader record with approval of adjustments
        /// Insert all trxLine record with adjustments under trxHeader
        /// </summary>
        public void Submit()
        {
            string trxHeaderIdoName = "CRMWarehouseLocationTrxHeader";
            string trxType          = "StockAdjust";
            string todayDate        = DateTime.UtcNow.ToString("yyyy-MM-ddThh:mm:ss.fffZ");
            string stockBin         = ThisForm.Variables("VarStockBin").Value;

            //INSERT TRX HEADER RECORD
            UpdateCollectionRequestData insert = new UpdateCollectionRequestData(trxHeaderIdoName);
            IDOUpdateItem itm = new IDOUpdateItem(UpdateAction.Insert);

            itm.Properties.Add("TrxType", trxType);
            itm.Properties.Add("TrxDate", todayDate);
            itm.Properties.Add("VanStockLocation", stockBin);
            itm.Properties.Add("Status", "Posted");
            insert.Items.Add(itm);

            try {
                IDOClient.UpdateCollection(insert);
            } catch (Exception e) {
                Application.ShowMessage("Unable to insert record to " + trxHeaderIdoName + "\n" + e.Message);
            }

            Application.ShowMessage("Successfully submitted TrxHeader at " + todayDate);

            //GET TRX HEADER ID FOR TRX LINES
            LoadCollectionRequestData trxHeaderLoadRequest = new LoadCollectionRequestData();

            trxHeaderLoadRequest.IDOName = trxHeaderIdoName;
            trxHeaderLoadRequest.PropertyList.Add("ID");
            trxHeaderLoadRequest.Filter    = "TrxDate = '" + todayDate + "'";
            trxHeaderLoadRequest.OrderBy   = "";
            trxHeaderLoadRequest.RecordCap = 1;
            LoadCollectionResponseData trxHeaderLoadResponse = IDOClient.LoadCollection(trxHeaderLoadRequest);

            if (trxHeaderLoadResponse.Items.Count != 1)
            {
                Application.ShowMessage("Could not load " + trxHeaderIdoName + " record with TrxDate = " + todayDate);
                return;
            }

            //INSERT TRX LINE RECORD
            insert = new UpdateCollectionRequestData("CRMWarehouseStockLotLocationTrx");

            ThisForm.PrimaryIDOCollection.First();
            for (int i = 0; i < ThisForm.PrimaryIDOCollection.GetNumEntries() - 1; i++)
            {
                string trxHeader      = trxHeaderLoadResponse[0, "ID"].Value;
                string productID      = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ProductID");
                string locationID     = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("LocationID");
                string lotCode        = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("StockLotCode");
                string systemQuantity = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("QuantityOnHand");
                string adjustment     = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("Adjustment");
                string reason         = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("Reason");

                Application.ShowMessage(productID + "\n" + locationID + "\n" + lotCode + "\n" + systemQuantity + "\n" + adjustment + "\n" + reason);

                //if adjustment is empty, skip
                if (adjustment.Equals(""))
                {
                    ThisForm.PrimaryIDOCollection.Next();
                    continue;
                }

                itm = new IDOUpdateItem(UpdateAction.Insert);
                itm.Properties.Add("TrxHeader", trxHeader);
                itm.Properties.Add("ProductID", productID);
                itm.Properties.Add("LocationID", locationID);
                itm.Properties.Add("StockLotCode", lotCode);
                itm.Properties.Add("QuantityOnHand", systemQuantity);
                itm.Properties.Add("CountAdjustment", adjustment);
                itm.Properties.Add("Reason", reason);
                insert.Items.Add(itm);

                ThisForm.PrimaryIDOCollection.Next();
            }

            try {
                IDOClient.UpdateCollection(insert);
            } catch (Exception e) {
                Application.ShowMessage("Unable to insert into CRMWarehouseStockLotLocationTrx\n" + e.Message);
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Validate the account if the owner is everyone or not
        /// Everyone: does not allow delete
        /// </summary>
        public void ValidateDelete()
        {
            string selectedOwner        = "SecCodeID";
            string selectedAccountName  = "AccountName";
            string showDetail           = ThisForm.Variables("VarShowDetail").GetValue <string>();
            string itemsCannotbeDeleted = string.Empty;

            if (string.Equals(showDetail, "0"))
            {
                itemsCannotbeDeleted = string.Empty;
                var rowCount = ThisForm.PrimaryIDOCollection.GetNumEntries();
                for (var i = 0; i < rowCount; i++)
                {
                    var currentRowValue    = ThisForm.PrimaryIDOCollection.GetObjectProperty(selectionProperty, i);
                    var currentRowOwner    = ThisForm.PrimaryIDOCollection.GetObjectProperty(selectedOwner, i);
                    var currentAccountName = ThisForm.PrimaryIDOCollection.GetObjectProperty(selectedAccountName, i);

                    var filter = string.Format("ID=N'{0}' and Type=N'{1}'", currentRowOwner, "System");

                    var AccountInfo = IDOClient.LoadCollection("CRMSeccodeView", "ID", filter, string.Empty, -1);

                    if (currentRowValue == "1")
                    {
                        if (AccountInfo.Items.Count > 0)
                        {
                            itemsCannotbeDeleted = itemsCannotbeDeleted + currentAccountName + ",";
                        }
                        else
                        {
                            ThisForm.GenerateEvent("StdFormDelete");
                            return;
                        }
                    }
                }
            }
            else
            {
                itemsCannotbeDeleted = string.Empty;
                var currentRowOwner    = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty(selectedOwner);
                var currentAccountName = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty(selectedAccountName);

                var filter = string.Format("ID=N'{0}' and Type=N'{1}'", currentRowOwner, "System");

                var AccountInfo = IDOClient.LoadCollection("CRMSeccodeView", "ID", filter, string.Empty, -1);

                if (AccountInfo.Items.Count > 0)
                {
                    itemsCannotbeDeleted = currentAccountName;
                }
                else
                {
                    ThisForm.GenerateEvent("StdFormDelete");
                    return;
                }
            }

            if (!string.IsNullOrEmpty(itemsCannotbeDeleted))
            {
                Application.ShowMessage(Application.GetStringValue("sCannotDeleteAccount").Replace("%1", itemsCannotbeDeleted));
            }
        }