public ContactDetailPageExercise(Contact2 contact)
        {
            // Note the use of nameof() operator in C# 6.
            if (contact == null)
            {
                throw new ArgumentNullException(nameof(contact));
            }
            InitializeComponent();
            // We do not use the given contact as the BindingContext.
            // The reason for this is that if the user make changes and
            // clicks the back button (instead of Save), the changes
            // should be reverted. So, we create a separate Contact object
            // based on the given Contact and use that temporarily on this
            // page. When Save is clicked, we raise an event and notify
            // others (in this case ContactsPage) that a contact is added or
            // updated.

            BindingContext = new Contact2
            {
                Id        = contact.Id,
                FirstName = contact.FirstName,
                LastName  = contact.LastName,
                Phone     = contact.Phone,
                Email     = contact.Email,
                IsBlocked = contact.IsBlocked
            };
        }
        protected void btnSumbitcontact_Click(object sender, EventArgs e)
        {
            Contact2 newobject = new Contact2();

            newobject.Client_Type      = Convert.ToInt32(DropDownListcontacttype2.SelectedValue);
            newobject.Contact_Location = TextBoxlocation.Text;

            newobject.Contact_Mobile = TextBoxmobile.Text;

            newobject.Contact_Name    = TextBoxContactName.Text;
            newobject.Contact_Note    = "Add From invoice page";
            newobject.Contact_Phone   = "00000";
            newobject.Contact_Rectime = DateTime.Now;

            newobject.IsDisable = false;
            newobject.Rectime   = DateTime.Now;
            newobject.UserID    = Convert.ToInt32(Session["userid"]);

            DB.Contact2s.InsertOnSubmit(newobject);
            DB.SubmitChanges();

            if (DropDownListinvoicetype.SelectedValue == "1")
            {
                DropDownListcontac.DataSource = DB.Contact2s.Where(a => a.IsDisable.Equals(false) && a.Client_Type.Equals(1)).Select(a => new { ID = a.Contact_Id, name = a.Contact_Name }).OrderByDescending(a => a.ID);
                DropDownListcontac.DataBind();
            }
            else if (DropDownListinvoicetype.SelectedValue == "2")
            {
                DropDownListcontac.DataSource = DB.Contact2s.Where(a => a.IsDisable.Equals(false) && a.Client_Type.Equals(3)).Select(a => new { ID = a.Contact_Id, name = a.Contact_Name }).OrderByDescending(a => a.ID);;
                DropDownListcontac.DataBind();
            }
        }
        private void Add_Contact_Click(object sender, RoutedEventArgs e)
        {
            Contact2 contact = new Contact2()
            {
                Name  = TxtName.Text,
                Phone = TxtPhone.Text,
            };

            this._service.Create2(contact);
            StatusAdd.Text = "Add Success";
        }
        public void GreaterThan_Test()
        {
            var contact = new Contact2
            {
                StartDate = DateTime.Parse("2000,1,1"),
                EndDate   = DateTime.Parse("1999,1,1")
            };
            var context = new ValidationContext(contact, null, null);
            var errors  = new List <ValidationResult>();

            if (!Validator.TryValidateObject(contact, context, errors, true))
            {
                Assert.AreEqual(1, errors.Count);
            }
        }
Beispiel #5
0
        protected void add()
        {
            Contact2 newobject = new Contact2();

            newobject.Client_Type                 = Convert.ToInt32(DropDownList1.SelectedValue);
            newobject.Contact_Location            = TextBoxlocation.Text;
            newobject.Contact_ManinCharge         = TextBoxpicname.Text;
            newobject.Contact_Mobile              = TextBoxmobile.Text;
            newobject.Contact_Mobile_ManinChaarge = TextBoxpicphone.Text;
            newobject.Contact_Name                = TextBoxContactName.Text;
            newobject.Contact_Note                = TextBoxNote.Text;
            newobject.Contact_Phone               = TextBoxphone.Text;
            newobject.Contact_Rectime             = DateTime.Now;
            newobject.Contact_Website             = TextBoxwebsite.Text;
            newobject.IsDisable = false;
            newobject.Rectime   = DateTime.Now;
            newobject.UserID    = Convert.ToInt32(Session["userid"]);

            DB.Contact2s.InsertOnSubmit(newobject);
            DB.SubmitChanges();
        }
            static void Main()
            {
                // Some simple data sources.
                string[] names = { "Terry Adams",  "Fadi Fakhouri", "Hanying Feng",
                                   "Cesar Garcia", "Debra Garcia" };
                string[] addresses = { "123 Main St.", "345 Cypress Ave.", "678 1st Ave",
                                       "12 108th St.", "89 E. 42nd St." };

                // Simple query to demonstrate object creation in select clause.
                // Create Contact objects by using a constructor.
                var query1 = from i in Enumerable.Range(0, 5)
                             select new Contact(names[i], addresses[i]);

                // List elements cannot be modified by client code.
                var list = query1.ToList();

                foreach (var contact in list)
                {
                    Console.WriteLine("{0}, {1}", contact.Name, contact.Address);
                }

                // Create Contact2 objects by using a static factory method.
                var query2 = from i in Enumerable.Range(0, 5)
                             select Contact2.CreateContact(names[i], addresses[i]);

                // Console output is identical to query1.
                var list2 = query2.ToList();

                // List elements cannot be modified by client code.
                // CS0272:
                // list2[0].Name = "Eugene Zabokritski";

                // Keep the console open in debug mode.
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
            }
Beispiel #7
0
        /// <summary>
        /// Main code activity function
        /// </summary>
        /// <param name="executionContext"></param>
        /// <param name="crmWorkflowContext"></param>
        public override void ExecuteCRMWorkFlowActivity(CodeActivityContext executionContext, LocalWorkflowContext crmWorkflowContext)
        {
            if (crmWorkflowContext == null)
            {
                throw new ArgumentNullException(nameof(crmWorkflowContext));
            }

            TracingService = executionContext.GetExtension <ITracingService>();
            Service        = crmWorkflowContext.OrganizationService;

            // 1. Validation
            var account     = this.Account.Get(executionContext);
            int contactRole = this.ContactRole.Get(executionContext);

            if (account == null)
            {
                TracingService.Trace("Account parameter not set.");

                return;
            }

            if (contactRole < 1)
            {
                TracingService.Trace("Contact Role parameter not set.");
                return;
            }

            TracingService.Trace("Getting Contacts for Account {0} and Contact Role : {1}", account.Id, contactRole);

            // 2. Processing - Query CRM for contacts of a given role and linked to the given account
            DataAccessContact dataAccess = new DataAccessContact(this.Service, this.TracingService);

            EntityReference [] contactEntityReferences = dataAccess.GetAccountContacts(account.Id, (Contact_AccountRoleCode)contactRole);

            // 3. Return contacts found
            if (contactEntityReferences == null)
            {
                // No contacts
                return;
            }

            int contactCount = 0;

            if (contactEntityReferences.Length > contactCount)
            {
                Contact1.Set(executionContext, contactEntityReferences[contactCount++]);
            }

            if (contactEntityReferences.Length > contactCount)
            {
                Contact2.Set(executionContext, contactEntityReferences[contactCount++]);
            }

            if (contactEntityReferences.Length > contactCount)
            {
                Contact3.Set(executionContext, contactEntityReferences[contactCount++]);
            }

            if (contactEntityReferences.Length > contactCount)
            {
                Contact4.Set(executionContext, contactEntityReferences[contactCount++]);
            }

            if (contactEntityReferences.Length > contactCount)
            {
                Contact5.Set(executionContext, contactEntityReferences[contactCount++]);
            }

            if (contactEntityReferences.Length > contactCount)
            {
                Contact6.Set(executionContext, contactEntityReferences[contactCount++]);
            }

            if (contactEntityReferences.Length > contactCount)
            {
                Contact7.Set(executionContext, contactEntityReferences[contactCount++]);
            }

            if (contactEntityReferences.Length > contactCount)
            {
                Contact8.Set(executionContext, contactEntityReferences[contactCount++]);
            }

            if (contactEntityReferences.Length > contactCount)
            {
                Contact9.Set(executionContext, contactEntityReferences[contactCount++]);
            }

            if (contactEntityReferences.Length > contactCount)
            {
                Contact10.Set(executionContext, contactEntityReferences[contactCount++]);
            }

            if (contactEntityReferences.Length > contactCount)
            {
                Contact11.Set(executionContext, contactEntityReferences[contactCount++]);
            }

            if (contactEntityReferences.Length > contactCount)
            {
                Contact12.Set(executionContext, contactEntityReferences[contactCount++]);
            }

            if (contactEntityReferences.Length > contactCount)
            {
                Contact13.Set(executionContext, contactEntityReferences[contactCount++]);
            }

            if (contactEntityReferences.Length > contactCount)
            {
                Contact14.Set(executionContext, contactEntityReferences[contactCount++]);
            }
            if (contactEntityReferences.Length > contactCount)
            {
                Contact15.Set(executionContext, contactEntityReferences[contactCount]);
            }
        }
Beispiel #8
0
        private static void ProcessValidation(ValidationFilter Filter, Contact record)
        {
            PXPrimaryGraphCollection primaryGraph = new PXPrimaryGraphCollection(new PXGraph());
            PXGraph graph = primaryGraph[record];

            if (graph == null)
            {
                throw new PXException(Messages.UnableToFindGraph);
            }

            PXView        view = graph.Views[graph.PrimaryView];
            int           startRow = 0, totalRows = 0;
            List <object> list_contact = view.Select(null, null, new object[] { record.ContactID }, new string[] { typeof(Contact.contactID).Name }, null, null,
                                                     ref startRow, 1, ref totalRows);

            if (list_contact == null || list_contact.Count < 1)
            {
                throw new PXException(Messages.ContactNotFound);
            }
            Contact contact = PXResult.Unwrap <Contact>(list_contact[0]);

            contact.DuplicateFound = true;
            //Find duplicates view
            PXView viewDuplicates = graph.Views.ToArray().First(v => v.Value.Cache.GetItemType() == typeof(CRDuplicateRecord)).Value;

            if (viewDuplicates == null)
            {
                throw new PXException(Messages.DuplicateViewNotFound);
            }
            viewDuplicates.Clear();
            List <object> duplicates = viewDuplicates.SelectMulti();

            contact = (Contact)view.Cache.CreateCopy(contact);
            string prevStatus = contact.DuplicateStatus;

            contact.DuplicateStatus = DuplicateStatusAttribute.Validated;
            Decimal?score = 0;

            contact.DuplicateFound = duplicates.Count > 0;
            foreach (PXResult <CRDuplicateRecord, Contact, Contact2> r in duplicates)
            {
                Contact2          duplicate    = r;
                CRDuplicateRecord contactScore = r;
                int duplicateWeight            = ContactMaint.GetContactWeight(duplicate);
                int currentWeight = ContactMaint.GetContactWeight(contact);

                if (duplicateWeight > currentWeight ||
                    (duplicateWeight == currentWeight &&
                     duplicate.ContactID < contact.ContactID))
                {
                    contact.DuplicateStatus = DuplicateStatusAttribute.PossibleDuplicated;
                    if (contactScore.Score > score)
                    {
                        score = contactScore.Score;
                    }
                }
            }
            view.Cache.Update(contact);

            if (contact.DuplicateStatus == DuplicateStatusAttribute.PossibleDuplicated &&
                contact.ContactType == ContactTypesAttribute.Lead &&
                contact.Status == LeadStatusesAttribute.New &&
                Filter.CloseNoActivityLeads == true &&
                score > Filter.CloseThreshold)
            {
                CRActivity activity = PXSelect <CRActivity,
                                                Where <CRActivity.contactID, Equal <Required <Contact.contactID> > > > .SelectWindowed(graph, 0, 1, contact.ContactID);

                if (activity == null)
                {
                    PXAction  action  = graph.Actions["Action"];
                    PXAdapter adapter = new PXAdapter(view);
                    adapter.StartRow    = 0;
                    adapter.MaximumRows = 1;
                    adapter.Searches    = new object[] { contact.ContactID };
                    adapter.Menu        = Messages.CloseAsDuplicate;
                    adapter.SortColumns = new[] { typeof(Contact.contactID).Name };
                    foreach (Contact c in action.Press(adapter))
                    {
                        ;
                    }
                    prevStatus = null;
                }
            }
            view.Cache.RestoreCopy(record, view.Cache.Current);
            if (prevStatus != contact.DuplicateStatus)
            {
                graph.Actions.PressSave();
            }
        }
Beispiel #9
0
        public void Add(Student student)
        {
            lock (student)
            {
                if (Count == StudentId.Length)
                {
                    var newLength  = StudentId.Length + 1000;
                    var _StudentId = new string[newLength];
                    StudentId.CopyTo(_StudentId);
                    StudentId = _StudentId;
                    var _IndexNumber = new string[newLength];
                    IndexNumber.CopyTo(_IndexNumber);
                    IndexNumber = _IndexNumber;
                    var _ReferenceNumber = new string[newLength];
                    ReferenceNumber.CopyTo(_ReferenceNumber);
                    ReferenceNumber = _ReferenceNumber;
                    var _Surname = new string[newLength];
                    Surname.CopyTo(_Surname);
                    Surname = _Surname;
                    var _Othernames = new string[newLength];
                    Othernames.CopyTo(_Othernames);
                    Othernames = _Othernames;
                    var _Title = new string[newLength];
                    Title.CopyTo(_Title);
                    Title = _Title;
                    var _Gender = new string[newLength];
                    Gender.CopyTo(_Gender);
                    Gender = _Gender;
                    var _MaritalStatus = new string[newLength];
                    MaritalStatus.CopyTo(_MaritalStatus);
                    MaritalStatus = _MaritalStatus;
                    var _DateofBirth = new string[newLength];
                    DateofBirth.CopyTo(_DateofBirth);
                    DateofBirth = _DateofBirth;
                    var _Disability = new bool[newLength];
                    Disability.CopyTo(_Disability);
                    Disability = _Disability;
                    var _Country = new string[newLength];
                    Country.CopyTo(_Country);
                    Country = _Country;
                    var _Region = new string[newLength];
                    Region.CopyTo(_Region);
                    Region = _Region;
                    var _HomeTown = new string[newLength];
                    HomeTown.CopyTo(_HomeTown);
                    HomeTown = _HomeTown;
                    var _Address1 = new string[newLength];
                    Address1.CopyTo(_Address1);
                    Address1 = _Address1;
                    var _Address2 = new string[newLength];
                    Address2.CopyTo(_Address2);
                    Address2 = _Address2;
                    var _Contact1 = new string[newLength];
                    Contact1.CopyTo(_Contact1);
                    Contact1 = _Contact1;
                    var _Contact2 = new string[newLength];
                    Contact2.CopyTo(_Contact2);
                    Contact2 = _Contact2;
                    var _PersonalEmail = new string[newLength];
                    PersonalEmail.CopyTo(_PersonalEmail);
                    PersonalEmail = _PersonalEmail;
                    var _UniversityEmail = new string[newLength];
                    UniversityEmail.CopyTo(_UniversityEmail);
                    UniversityEmail = _UniversityEmail;
                    var _ResidentialStatus = new string[newLength];
                    ResidentialStatus.CopyTo(_ResidentialStatus);
                    ResidentialStatus = _ResidentialStatus;
                    var _ProgramOfStudy = new string[newLength];
                    ProgramOfStudy.CopyTo(_ProgramOfStudy);
                    ProgramOfStudy = _ProgramOfStudy;
                    var _Specialization = new string[newLength];
                    Specialization.CopyTo(_Specialization);
                    Specialization = _Specialization;
                    var _ProgramStatus = new string[newLength];
                    ProgramStatus.CopyTo(_ProgramStatus);
                    ProgramStatus = _ProgramStatus;
                    var _Level = new string[newLength];
                    Level.CopyTo(_Level);
                    Level = _Level;
                    var _StudentType = new string[newLength];
                    StudentType.CopyTo(_StudentType);
                    StudentType = _StudentType;
                    var _EnrollmentOption = new string[newLength];
                    EnrollmentOption.CopyTo(_EnrollmentOption);
                    EnrollmentOption = _EnrollmentOption;
                    var _RegistrationStatus = new string[newLength];
                    RegistrationStatus.CopyTo(_RegistrationStatus);
                    RegistrationStatus = _RegistrationStatus;
                    var _DateOfEntry = new System.DateTime[newLength];
                    DateOfEntry.CopyTo(_DateOfEntry);
                    DateOfEntry = _DateOfEntry;
                    var _DateOfCompletion = new System.DateTime[newLength];
                    DateOfCompletion.CopyTo(_DateOfCompletion);
                    DateOfCompletion = _DateOfCompletion;
                    var _Results = new StudentResultDM[newLength];;
                    Results.CopyTo(_Results);
                    Results = _Results;
                    var _RegisteredCourses = new RegisteredCourseDM[newLength];
                    RegisteredCourses.CopyTo(_RegisteredCourses);
                    RegisteredCourses = _RegisteredCourses;
                    var _EmergencyContact = new EmergencyContactDM[newLength];
                    EmergencyContact.CopyTo(_EmergencyContact);
                    EmergencyContact = _EmergencyContact;
                    var _Owning = new bool[newLength];
                    //Owning.CopyTo(_Owning);
                    //Owning = _Owning;
                    //var _FeesBalance = new string[newLength];
                    //FeesBalance.CopyTo(_FeesBalance);
                    //FeesBalance = _FeesBalance;
                    var _PamentOption = new string[newLength];
                    PamentOption.CopyTo(_PamentOption);
                    PamentOption = _PamentOption;
                    var _DepartmentId = new string[newLength];
                    DepartmentId.CopyTo(_DepartmentId);
                    DepartmentId = _DepartmentId;
                    var _State = new int[newLength];
                    State.CopyTo(_State);
                    State = _State;
                }
                StudentId.Span[Count]          = student.StudentId;
                IndexNumber.Span[Count]        = student.IndexNumber;
                ReferenceNumber.Span[Count]    = student.ReferenceNumber;
                Surname.Span[Count]            = student.Surname;
                Othernames.Span[Count]         = student.Othernames;
                Title.Span[Count]              = student.Title;
                Gender.Span[Count]             = student.Gender;
                MaritalStatus.Span[Count]      = student.MaritalStatus;
                DateofBirth.Span[Count]        = student.DateofBirth;
                Disability.Span[Count]         = student.Disability;
                Country.Span[Count]            = student.Country;
                Region.Span[Count]             = student.Region;
                HomeTown.Span[Count]           = student.HomeTown;
                Address1.Span[Count]           = student.Address1;
                Address2.Span[Count]           = student.Address2;
                Contact1.Span[Count]           = student.Contact1;
                Contact2.Span[Count]           = student.Contact2;
                PersonalEmail.Span[Count]      = student.PersonalEmail;
                UniversityEmail.Span[Count]    = student.UniversityEmail;
                ResidentialStatus.Span[Count]  = student.ResidentialStatus;
                ProgramOfStudy.Span[Count]     = student.ProgramOfStudy;
                Specialization.Span[Count]     = student.Specialization;
                ProgramStatus.Span[Count]      = student.ProgramStatus;
                Level.Span[Count]              = student.Level;
                StudentType.Span[Count]        = student.StudentType;
                EnrollmentOption.Span[Count]   = student.EnrollmentOption;
                RegistrationStatus.Span[Count] = student.RegistrationStatus;
                DateOfEntry.Span[Count]        = student.DateOfEntry;
                DateOfCompletion.Span[Count]   = student.DateOfCompletion;

                //Owning.Span[Count] = student.Owning;
                //FeesBalance.Span[Count] = student.FeesBalance;
                PamentOption.Span[Count] = student.PamentOption;
                DepartmentId.Span[Count] = student.DepartmentId;
                State.Span[Count]++;
                Count++;

                Results.Span[Count] = new StudentResultDM(length);
                if (student.Results?.Count > 0)
                {
                    foreach (var t in student.Results)
                    {
                        Results.Span[Count].Add(t);
                    }
                }

                EmergencyContact.Span[Count] = new EmergencyContactDM(length);
                if (student.EmergencyContact?.Count > 0)
                {
                    foreach (var t in student.EmergencyContact)
                    {
                        EmergencyContact.Span[Count].Add(t);
                    }
                }

                RegisteredCourses.Span[Count] = new RegisteredCourseDM(length);
                if (student.RegisteredCourses?.Count > 0)
                {
                    foreach (var t in student.RegisteredCourses)
                    {
                        RegisteredCourses.Span[Count].Add(t);
                    }
                }
            }
        }
Beispiel #10
0
 public void Create2(Contact2 contact2)
 {
     memberModel.Save2(contact2);
 }
Beispiel #11
0
        public void ProcessRequest(HttpContext context)
        {
            ManagementService managementservice = new ManagementService();
            ScopeServices     scopeservices     = new ScopeServices();

            managementservice.SQLConnection = ConnectDb.SQLConnection;
            UserProfile contactProfile = new UserProfile();
            Project     project        = new Project();
            User        contactUser    = new User();
            long        userId;
            string      FirstName; string LastName;
            string      Email;
            string      Contact1; string Contact2; string Contact3;
            string      Address;
            string      Suburb; int SuburbId; string City; int CityId;
            string      PostCode; string Region; int RegionId;
            string      Country; int CountryId;
            string      ProjectName; string ClaimNumber; string EstimatedTime;
            string      StartDate = ""; string ScopeDate = "";
            string      AssessmentDate = ""; string QuotationDate = "";
            string      FinishDate = ""; string ProjectGroupName;
            int         ProjectGroupId; int Priority; string Hazard; int status;

            try { userId = Convert.ToInt32(context.Request.QueryString["userId"]); }
            catch { userId = 0; }
            try { FirstName = context.Request.QueryString["FirstName"]; }
            catch { FirstName = ""; }
            try { LastName = context.Request.QueryString["LastName"]; }
            catch { LastName = ""; }
            try { Email = context.Request.QueryString["Email"]; }
            catch { Email = ""; }
            try { Contact1 = context.Request.QueryString["Contact1"]; }
            catch { Contact1 = ""; }
            try { Contact2 = context.Request.QueryString["Contact2"]; }
            catch { Contact2 = ""; }
            try { Contact3 = context.Request.QueryString["Contact3"]; }
            catch { Contact3 = ""; }
            try { Address = context.Request.QueryString["Address"]; }
            catch { Address = ""; }
            try { Suburb = context.Request.QueryString["Suburb"]; }
            catch { Suburb = ""; }
            try { SuburbId = Convert.ToInt32(context.Request.QueryString["SuburbId"]); }
            catch { SuburbId = 0; }
            try { City = context.Request.QueryString["City"]; }
            catch { City = ""; }
            try { CityId = Convert.ToInt32(context.Request.QueryString["CityId"]); }
            catch { CityId = 0; }
            try { PostCode = context.Request.QueryString["PostCode"]; }
            catch { PostCode = ""; }
            try { Region = context.Request.QueryString["Region"]; }
            catch { Region = ""; }
            try { RegionId = Convert.ToInt32(context.Request.QueryString["RegionId"]); }
            catch { RegionId = 0; }
            try { Country = context.Request.QueryString["Country"]; }
            catch { Country = ""; }
            try { CountryId = Convert.ToInt32(context.Request.QueryString["CountryId"]); }
            catch { CountryId = 0; }
            try { ProjectName = context.Request.QueryString["ProjectName"]; }
            catch { ProjectName = ""; }
            try { ClaimNumber = context.Request.QueryString["ClaimNumber"]; }
            catch { ClaimNumber = ""; }
            try { EstimatedTime = context.Request.QueryString["EstimatedTime"]; }
            catch { EstimatedTime = ""; }
            try { StartDate = context.Request.QueryString["StartDate"]; }
            catch { }
            try { ScopeDate = context.Request.QueryString["ScopeDate"]; }
            catch { }
            try { AssessmentDate = context.Request.QueryString["AssessmentDate"]; }
            catch { }
            try { QuotationDate = context.Request.QueryString["QuotationDate"]; }
            catch { }
            try { FinishDate = context.Request.QueryString["FinishDate"]; }
            catch { }
            try { ProjectGroupName = context.Request.QueryString["ProjectGroupName"]; }
            catch { ProjectGroupName = ""; }
            try { ProjectGroupId = Convert.ToInt32(context.Request.QueryString["ProjectGroupId"]); }
            catch { ProjectGroupId = 0; }
            try { Priority = Convert.ToInt32(context.Request.QueryString["Priority"]); }
            catch { Priority = 0; }
            try { Hazard = context.Request.QueryString["Hazard"]; }
            catch { Hazard = ""; }
            try { status = Convert.ToInt32(context.Request.QueryString["status"]); }
            catch { status = 0; }

            contactUser.Email = Email.Trim();
            contactUser.Type  = 0;
            userId            = managementservice.CreateUser(contactUser, userId);

            long userProfileId;

            contactProfile.UserId        = userId;
            contactProfile.FirstName     = FirstName.Trim();
            contactProfile.LastName      = LastName.Trim();
            contactProfile.Contact1      = Contact1.Trim();
            contactProfile.Contact2      = Contact2.Trim();
            contactProfile.Contact3      = Contact3.Trim();
            contactProfile.Email         = Email.Trim();
            userProfileId                = managementservice.CreateUserProfile(contactProfile);
            contactProfile.UserProfileId = userProfileId;

            VoucherCodeFunctions cVoucherCode = new VoucherCodeFunctions();
            String strIdentifier = String.Format("{0}{1}", userProfileId, cVoucherCode.GenerateVoucherCodeGuid(16));

            contactProfile.Identifier = strIdentifier;

            managementservice.UpdateUserProfileIdentifier(contactProfile);
            string filename = DateTime.UtcNow.ToString("yyyyMMddHHmmss");
            string fname = "", virtualpath = "";

            System.Text.StringBuilder str = new System.Text.StringBuilder();
            try
            {
                if (context.Request.Files.Count > 0)
                {
                    HttpFileCollection files = context.Request.Files;

                    string myactualfilename = "";
                    for (int i = 0; i < files.Count; i++)
                    {
                        HttpPostedFile file = files[i];
                        myactualfilename = file.FileName;
                        var p = file.FileName.Split('.');

                        var    extention = myactualfilename.Split('.');
                        string ext       = extention[extention.Length - 1];
                        filename = filename + '.' + ext;
                        string projectpath = "http://koreprojects.com";
                        string folderPath  = context.Server.MapPath(projectpath + "/Images/" + contactProfile.Identifier);
                        if (!System.IO.Directory.Exists(folderPath))
                        {
                            System.IO.Directory.CreateDirectory(folderPath);
                        }
                        fname = context.Server.MapPath(projectpath + "/Images/" + contactProfile.Identifier + "/" + filename);

                        file.SaveAs(fname);
                        //context.Response.Write(filename);
                    }
                }
            }
            catch
            {
                //context.Response.Write("un");
            }
            if (filename != String.Empty)
            {
                contactProfile.PersonalPhoto = filename;
            }

            managementservice.UpdateUserProfile(contactProfile);

            project.ContactId      = userId;
            project.ProjectOwnerId = managementservice.GetProjectOwnerByContactId(userId).ProjectOwnerId;
            project.Address        = Address.Trim();
            project.Suburb         = Suburb;
            if (Suburb != string.Empty)
            {
                project.SuburbID = SuburbId;
            }

            project.City = City;
            if (City != string.Empty)
            {
                project.CityID = CityId;
            }
            project.Region = Region;
            if (RegionId > 0)
            {
                project.RegionID = RegionId;
            }
            project.Country = Country;
            if (CountryId > 0)
            {
                project.CountryID = CountryId;
            }
            project.Name           = ProjectName.Trim();
            project.EQCClaimNumber = ClaimNumber.Trim();
            project.EstimatedTime  = EstimatedTime.Trim();

            project.StartDate = Convert.ToDateTime(StartDate);

            project.ScopeDate = Convert.ToDateTime(ScopeDate);

            project.ProjectStatusId = 0;
            if (ProjectGroupId > 0)
            {
                project.GroupID   = ProjectGroupId;
                project.GroupName = ProjectGroupName;
            }
            else
            {
                project.GroupID   = 0;
                project.GroupName = String.Empty;
            }

            project.AssessmentDate = Convert.ToDateTime(AssessmentDate);
            project.QuotationDate  = Convert.ToDateTime(QuotationDate);
            project.FinishDate     = Convert.ToDateTime(FinishDate);
            project.Priority       = Priority;
            project.Hazard         = Hazard.Trim();

            long newProjectId;

            newProjectId      = managementservice.CreateProject(project);
            project.ProjectId = newProjectId;

            UserProjectStatusValue userProjectStatusValue = new UserProjectStatusValue();

            userProjectStatusValue.ProjectId = project.ProjectId;
            userProjectStatusValue.UserId    = userId;
            userProjectStatusValue.UserProjectStatusValue = status;
            managementservice.CreateUserProjectStatusValue(userProjectStatusValue);
            int projectCredit             = 0;

            try
            {
                DataSet dsUserAccount = new DataSet();
                dsUserAccount = managementservice.GetUserAccountByUserID(userId);
                if (dsUserAccount.Tables[0].Rows.Count > 0)
                {
                    projectCredit = int.Parse(dsUserAccount.Tables[0].Rows[0]["ProjectCredit"].ToString());
                }

                if (projectCredit > 0)
                {
                    managementservice.UpdateUserAccount(userId, projectCredit - 1);
                    managementservice.CreateUserTransaction(userId, String.Format("Create Project", project.Name), 0, 0, -1, projectCredit - 1);
                }
            }
            catch (Exception w)
            { }

            context.Response.ContentType = "image/jpg";
            context.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
        }
Beispiel #12
0
        public ShipmentValidateResponse CreateBox(Box box, DirectLine directLine)
        {
            ShipmentValidateResponse  result;
            ShipmentValidateRequestEA shipment = new ShipmentValidateRequestEA();

            shipment.Request = requsetInit();
            //shipment.NewShipper = YesNo1.N;
            //shipment.NewShipperSpecified = true;
            shipment.LanguageCode           = "tw";
            shipment.PiecesEnabled          = PiecesEnabled.Y;
            shipment.PiecesEnabledSpecified = true;
            shipment.Reference = new Reference1[] { new Reference1()
                                                    {
                                                        ReferenceID = box.BoxID
                                                    } };
            shipment.LabelImageFormat           = LabelImageFormat.PDF;
            shipment.LabelImageFormatSpecified  = true;
            shipment.RequestArchiveDoc          = YesNo1.Y;
            shipment.RequestArchiveDocSpecified = true;
            shipment.Label = new Label()
            {
                LabelTemplate = "8X4_A4_PDF"
            };

            shipment.Billing = new Billing1()
            {
                ShipperAccountNumber     = api_account,
                ShippingPaymentType      = ShipmentPaymentType.S,
                BillingAccountNumber     = api_account,
                DutyPaymentType          = DutyTaxPaymentType1.S,
                DutyPaymentTypeSpecified = true,
                DutyAccountNumber        = api_account
            };

            Contact2 contact = new Contact2()
            {
                PersonName  = directLine.ContactName,
                PhoneNumber = directLine.PhoneNumber
            };

            shipment.Consignee = new Consignee1()
            {
                CompanyName = !string.IsNullOrEmpty(directLine.CompanyName) ? directLine.CompanyName : contact.PersonName,
                AddressLine = new string[] { directLine.StreetLine1, directLine.StreetLine2 },
                City        = directLine.City,
                Division    = directLine.StateName,
                PostalCode  = directLine.PostalCode,
                CountryCode = directLine.CountryCode,
                CountryName = directLine.CountryName,
                Contact     = contact
            };

            List <Items>  itemList  = box.Packages.Where(p => p.IsEnable.Value).SelectMany(p => p.Items.Where(i => i.IsEnable.Value)).ToList();
            List <Piece2> pieceList = new List <Piece2>();

            pieceList.Add(new Piece2()
            {
                PackageType   = PackageType1.YP,
                Weight        = itemList.Sum(i => i.Qty.Value * ((decimal)i.Skus.Weight / 1000)),
                PieceContents = itemList.First().Skus.ProductType.ProductTypeName
            });

            shipment.ShipmentDetails = new ShipmentDetails2()
            {
                NumberOfPieces    = pieceList.Count().ToString(),
                Pieces            = pieceList.ToArray(),
                Weight            = pieceList.Sum(p => p.Weight),
                WeightUnit        = WeightUnit.K,
                GlobalProductCode = "P",
                LocalProductCode  = "P",
                Date                   = DateTime.Now,
                Contents               = string.Join(", ", itemList.Select(i => i.Skus.ProductType.ProductTypeName).Distinct().ToArray()),
                DoorTo                 = DoorTo.DD,
                DoorToSpecified        = true,
                DimensionUnit          = DimensionUnit.C,
                DimensionUnitSpecified = true,
                //InsuredAmount = "0.00",
                PackageType         = PackageType1.YP,
                IsDutiable          = YesNo1.Y,
                IsDutiableSpecified = true,
                CurrencyCode        = Enum.GetName(typeof(QDLogistics.OrderService.CurrencyCodeType2), box.Packages.First().Orders.OrderCurrencyCode.Value)
            };

            shipment.Dutiable = new Dutiable1()
            {
                DeclaredValue    = box.Packages.Sum(p => p.DeclaredTotal).ToString(),
                DeclaredCurrency = shipment.ShipmentDetails.CurrencyCode,
                TermsOfTrade     = "DDP"
            };

            shipment.Shipper = new Shipper1()
            {
                ShipperID   = api_account,
                CompanyName = "Zhi You Wan LTD",
                AddressLine = new string[] { "No.51, Sec.3 Jianguo N. Rd.,", "South Dist.," },
                City        = "Taichung City",
                PostalCode  = "403",
                CountryCode = "TW",
                CountryName = "Taiwan",
                Contact     = new Contact2()
                {
                    PersonName = "Huai Wei Ho", PhoneNumber = "0423718118"
                }
            };

            shipment.SpecialService = new SpecialService1[] { new SpecialService1()
                                                              {
                                                                  SpecialServiceType = "DD",
                                                                  ChargeValue        = shipment.Dutiable.DeclaredValue,
                                                                  CurrencyCode       = shipment.Dutiable.DeclaredCurrency
                                                              } };

            XmlSerializer serializer = new XmlSerializer(typeof(ShipmentValidateResponse));
            string        request    = SendRequest(shipment);

            using (TextReader reader = new StringReader(request))
            {
                try
                {
                    result = (ShipmentValidateResponse)serializer.Deserialize(reader);
                }
                catch (Exception e)
                {
                    TextReader    errorReader           = new StringReader(request);
                    XmlSerializer errorSerializer       = new XmlSerializer(typeof(ShipmentValidateErrorResponse));
                    ShipmentValidateErrorResponse error = errorSerializer.Deserialize(errorReader) as ShipmentValidateErrorResponse;
                    errorReader.Dispose();
                    throw new Exception(string.Join("; ", error.Response.Status.Condition.Select(c => c.ConditionData)));
                }
            }

            return(result);
        }
Beispiel #13
0
        private ShipmentValidateRequestEA setShipment(Packages package)
        {
            var shipment = new ShipmentValidateRequestEA();

            shipment.Request = requsetInit();
            //shipment.NewShipper = YesNo1.N;
            //shipment.NewShipperSpecified = true;
            shipment.LanguageCode           = "tw";
            shipment.PiecesEnabled          = PiecesEnabled.Y;
            shipment.PiecesEnabledSpecified = true;
            shipment.Reference = new Reference1[] { new Reference1()
                                                    {
                                                        ReferenceID = package.OrderID.ToString()
                                                    } };
            shipment.LabelImageFormat           = LabelImageFormat.PDF;
            shipment.LabelImageFormatSpecified  = true;
            shipment.RequestArchiveDoc          = YesNo1.Y;
            shipment.RequestArchiveDocSpecified = true;
            shipment.Label = new Label()
            {
                LabelTemplate = "8X4_A4_PDF"
            };

            shipment.Billing = new Billing1()
            {
                ShipperAccountNumber     = api_account,
                ShippingPaymentType      = ShipmentPaymentType.S,
                BillingAccountNumber     = api_account,
                DutyPaymentType          = DutyTaxPaymentType1.S,
                DutyPaymentTypeSpecified = true,
                DutyAccountNumber        = api_account
            };

            Addresses address = package.Orders.Addresses;
            Contact2  contact = new Contact2()
            {
                PersonName  = string.Join(" ", new string[] { address.FirstName, address.MiddleInitial, address.LastName }),
                PhoneNumber = address.PhoneNumber
            };

            shipment.Consignee = new Consignee1()
            {
                CompanyName = !string.IsNullOrEmpty(address.CompanyName) ? address.CompanyName : contact.PersonName,
                AddressLine = new string[] { address.StreetLine1, address.StreetLine2 },
                City        = address.City,
                Division    = address.StateName,
                PostalCode  = address.PostalCode,
                CountryCode = address.CountryCode,
                CountryName = address.CountryName,
                Contact     = contact
            };

            List <Piece2> pieceList = new List <Piece2>();

            pieceList.Add(new Piece2()
            {
                PackageType   = PackageType1.YP,
                Weight        = package.Items.Sum(i => i.Qty.Value * ((decimal)i.Skus.Weight / 1000)),
                PieceContents = package.Items.First(i => i.IsEnable.Equals(true)).Skus.ProductType.ProductTypeName
            });

            shipment.ShipmentDetails = new ShipmentDetails2()
            {
                NumberOfPieces    = pieceList.Count().ToString(),
                Pieces            = pieceList.ToArray(),
                Weight            = pieceList.Sum(p => p.Weight),
                WeightUnit        = WeightUnit.K,
                GlobalProductCode = "P",
                LocalProductCode  = "P",
                Date                   = DateTime.Now,
                Contents               = string.Join(", ", package.Items.Select(i => i.Skus.ProductType.ProductTypeName).Distinct().ToArray()),
                DoorTo                 = DoorTo.DD,
                DoorToSpecified        = true,
                DimensionUnit          = DimensionUnit.C,
                DimensionUnitSpecified = true,
                //InsuredAmount = "0.00",
                PackageType         = PackageType1.YP,
                IsDutiable          = YesNo1.Y,
                IsDutiableSpecified = true,
                CurrencyCode        = Enum.GetName(typeof(QDLogistics.OrderService.CurrencyCodeType2), package.Orders.OrderCurrencyCode.Value)
            };

            shipment.Dutiable = new Dutiable1()
            {
                DeclaredValue    = package.DeclaredTotal.ToString(),
                DeclaredCurrency = shipment.ShipmentDetails.CurrencyCode,
                TermsOfTrade     = "DDP"
            };

            shipment.Shipper = new Shipper1()
            {
                ShipperID   = api_account,
                CompanyName = "Zhi You Wan LTD",
                AddressLine = new string[] { "No.51, Sec.3 Jianguo N. Rd.,", "South Dist.," },
                City        = "Taichung City",
                PostalCode  = "403",
                CountryCode = "TW",
                CountryName = "Taiwan",
                Contact     = new Contact2()
                {
                    PersonName = "Huai Wei Ho", PhoneNumber = "0423718118"
                }
            };

            shipment.SpecialService = new SpecialService1[] { new SpecialService1()
                                                              {
                                                                  SpecialServiceType = "DD",
                                                                  ChargeValue        = package.DeclaredTotal.ToString(),
                                                                  CurrencyCode       = shipment.ShipmentDetails.CurrencyCode
                                                              } };

            return(shipment);
        }
    public string Subscribe(string email, string firstname, string lastname, string prefix, string street, string city, string state, string zip, string phone, string source, string interest)
    {
        bool success = false;

        string _output = "-1";
        try
        {
            Uri uri = new Uri(baseUrl + AccountId + "/c/" + ClientFolderId + "/contacts/");
            Contact2 c = new Contact2();
            c.email = email;
            c.status = "normal";
            c.firstName = firstname;
            c.lastName = lastname;
            c.prefix = prefix;
            c.state = state;
            c.street = street;
            c.postalCode = zip;
            c.phone = phone;
            c.city = city;
            c.source = source;

            var jsonSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();

            string json = jsonSerializer.Serialize(c);

            json = "[" + json + "]";

            // Create a new request to the above mentioned URL.

            HttpWebRequest r = (HttpWebRequest)WebRequest.Create(uri);

            r.Method = "POST";
            r.Accept = "application/json";
            r.Headers.Add("Api-Version", "2.0");
            r.Headers.Add("Api-AppId", AppId);
            r.Headers.Add("Api-Username", Username);
            r.Headers.Add("Api-Password", Password);
            // r.Headers.Add("Accept", "application/json");
            r.ContentType = "application/json";

            string data = json;
            byte[] dataStream = Encoding.UTF8.GetBytes(data);
            r.ContentLength = dataStream.Length;
            // Assign the response object of 'WebRequest' to a 'WebResponse' variable.

            Stream s = r.GetRequestStream();
            // Send the data.
            s.Write(dataStream, 0, dataStream.Length);
            s.Close();

            HttpWebResponse resp = (HttpWebResponse)r.GetResponse();
            System.IO.StreamReader sr = null;
            string sResponse = null;
            sResponse = "";
            sr = new StreamReader(resp.GetResponseStream());
            sResponse = sr.ReadToEnd();

            _output = sResponse;
            success = true;
        }
        catch
        {
            success = false;
        }

        string _parsed = "";
        Rootobject peoples = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<Rootobject>(_output);

           List<string> mailList = new List<string>();

        if (interest == "BetterMan") {
            mailList.Add("32692");	 // BetterMan Free Report
        } else if (interest == "BetterWoman")
        {
            mailList.Add("32693"); // BetterWoman Free Report
        }
        else
        {
             mailList.Add("32692");	 // BetterMan Free Report
             mailList.Add("32693"); // BetterWoman Free Report
        }

        foreach (var item in peoples.contacts)
        {
            _parsed = String.Format("Name: {0}, ID: {1}", item.firstName, item.contactId);

            foreach (string list in mailList)
            {
                AddToList(item.contactId, list, "normal");
            }

        }

        return _parsed;
    }